package com.web.dao;

import com.web.entity.Account;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @author FDjavaone
 */
public class AccountSqlProvider {


    public String insertSelective(Account record) {
        BEGIN();
        INSERT_INTO("t_account");

        if (record.getmId() != null) {
            VALUES("m_id", "#{mId,jdbcType=BIGINT}");
        }

        if (record.getProfit() != null) {
            VALUES("profit", "#{profit,jdbcType=DECIMAL}");
        }

        if (record.getConsumption() != null) {
            VALUES("consumption", "#{consumption,jdbcType=DECIMAL}");
        }

        if (record.getMerchantPayment() != null) {
            VALUES("merchant_payment", "#{merchantPayment,jdbcType=DECIMAL}");
        }

        if (record.getOriginalIntegral() != null) {
            VALUES("original_integral", "#{originalIntegral,jdbcType=DECIMAL}");
        }

        if (record.getCorePoints() != null) {
            VALUES("core_points", "#{corePoints,jdbcType=DECIMAL}");
        }

        if (record.getMsk() != null) {
            VALUES("msk", "#{msk,jdbcType=DECIMAL}");
        }

        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            VALUES("modify_time", "#{modifyTime,jdbcType=TIMESTAMP}");
        }

        return SQL();
    }


    public String updateByPrimaryKeySelective(Account record) {
        BEGIN();
        UPDATE("t_account");

        if (record.getmId() != null) {
            SET("m_id = #{mId,jdbcType=BIGINT}");
        }

        if (record.getProfit() != null) {
            SET("profit = #{profit,jdbcType=DECIMAL}");
        }

        if (record.getConsumption() != null) {
            SET("consumption = #{consumption,jdbcType=DECIMAL}");
        }

        if (record.getMerchantPayment() != null) {
            SET("merchant_payment = #{merchantPayment,jdbcType=DECIMAL}");
        }

        if (record.getOriginalIntegral() != null) {
            SET("original_integral = #{originalIntegral,jdbcType=DECIMAL}");
        }

        if (record.getCorePoints() != null) {
            SET("core_points = #{corePoints,jdbcType=DECIMAL}");
        }

        if (record.getMsk() != null) {
            SET("msk = #{msk,jdbcType=DECIMAL}");
        }

        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }

        if (record.getModifyTime() != null) {
            SET("modify_time = #{modifyTime,jdbcType=TIMESTAMP}");
        }

        WHERE("id = #{id,jdbcType=BIGINT}");

        return SQL();
    }

}